package club.itstudio.IContainer.controller.admin;

import club.itstudio.IContainer.annotation.AdminRequired;
import club.itstudio.IContainer.annotation.LoginRequired;
import club.itstudio.IContainer.entity.WebMenu;
import club.itstudio.IContainer.util.Result;
import club.itstudio.IContainer.util.ResultUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * @ClassName AdminWebMenuController
 * @Author alex
 * Date 2021/4/26 3:27 下午
 * Version 1.0
 **/
@RestController
@RequestMapping("/admin/menu")
public class AdminWebMenuController {

    private static List<WebMenu> mainMenu;

    static {
        // 主页
//        WebMenu homeMenu = new WebMenu("main", "主页", "layui-icon-home", "/", null);
        // 容器管理
        WebMenu containerMenu = new WebMenu("containerMenu", "容器管理", "layui-icon-app", "/menu/container/containerList", null);
        // 用户管理
        WebMenu studentMenu = new WebMenu("studentMenu", "学生管理", null, "/menu/user/student", null);
        WebMenu teacherMenu = new WebMenu("teacherMenu", "教师管理", null, "/menu/user/teacher", null);
        WebMenu userMenu = new WebMenu("userMenu", "用户管理", "layui-icon-user", null,
                new ArrayList<>(Arrays.asList(studentMenu, teacherMenu)));

        // 总菜单
        mainMenu = new ArrayList<>(Arrays.asList(containerMenu, userMenu));

    }

    @LoginRequired
    @AdminRequired
    @GetMapping
    public Result getAdminWebMenu() {
        return ResultUtil.success(mainMenu);
    }
}
